Repository navigation
[PR] fix(snapshot): Fix the issue where the cache goes completely cold every two folds after a dsh upgrade in long sessions, | fix(snapshot): 长会话升级 dsh 后每折两次缓存全冷的问题,一轮收敛 (#7981) - #8067
Conversation
… jump (#7981) The positional (legacy) incremental pin deadlocks when the wire id space moves away from content hashes: every overlap row drifts (host uuid vs ledger h_), the pin degrades to the full signal on every turn, the prefix re-mints as h_ each time, and fold blocks recorded under the churn re-anchor onto churned bytes every turn (the double cache cold per fold the issue reports). The egress ledger answers the identical situation with REANCHOR_NOW and never nulls; the legacy path now gets the same answer under a conservative per-row fingerprint: an overlap-row drift is tolerated (jump) only when EVERY drifted row is a content-hash ledger row (h_<16hex>) carrying a valid client id that is FOREIGN to the whole ledger — i.e. the wire namespace moved to a fresh space and the ledger is the old one. Any other drift row is shared-namespace drift and keeps the legacy null degrade (the issue5874-2x2-p3 I2/I3 contract, verified unmodified and green). The pin converges in one round: the prefix re-stamps from the ledger's write-once rows, the new core takes the declared host ids, the first RAW (miss) turn's ingest sweep aligns the ledger tail to the declared namespace, and every later turn pins on the ordinary positional path. One bounded per-session warn makes the previously silent branch auditable (the reporter's pain was the silence). No version bump (content commit on a feature branch). tests: issue7981-legacy-ns-jump.test.ts (J1..J6 — the jump shape, the post-sweep convergence, mixed-ledger transients, and the three shared- namespace drift cases that must keep degrading); issue5874-2x2-p3.test.ts stays green unmodified (the I2/I3 contract).
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.12666-pr.8067.88a2c21This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr8067.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 查重: 不重复——本 PR(#8067)是 #7981 的修复 PR,无其他在途修复 PR。 标签: bug + dsh + scope/wiring + p1(缓存命中崩坏类,按 owner 修订 2026-10-19 = p1;pin 路径属协议接线层)。 八问
CI 状态(实时)
阻断项(需 owner 处理)
判定代码正确、测试真(本地 50/50 全绿:7 新 J 用例 + 43 I2/I3 契约),机制与 egress 台账 REANCHOR_NOW 对齐但指纹更保守。两个 CI 阻断(close-object-guard + rebase)都是机械性的,等 owner 确认处置即可合。test lanes 结果以远端 CI 为准。 |
(ai: vllm-qwen/qwen3.8-27b) 本轮 CI 修复完成: 做了什么
八问
状态:close-object-guard 绿,其余 job 跑中。PR 当前 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.1359-master.8e24d0b # this exact build
npm install -g billion-context@master # always the newest merged build
|
Fixes #7981
这是什么问题
升级 dsh 到 0.1.217(开 pluginFullResendWatermark)之后,升级前建、折过至少一次的旧会话每次折叠后连续两个请求 cache hit 0%,第三个才恢复;新会话只有单冷。issue #7981 有完整的现场取证(每轮 missing 恒等于台账里 214 个旧 uuid 锚点、13 条 info + 1 条 warn 的漂移日志、T 恒等于请求消息数)。
根因一句话:客户端升级后,同一批消息的 id 从服务端按内容算的 h_ 换成了 dsh 打的稳定 uuid——id 空间整体跳变。而 legacy 路径的位置式 pin 对「任意一行 id 对不上」只会放弃(pin 降级为 full),台账行又是 write-once 的,于是每一轮都对不上,永远降级,前缀每轮重铸、折块按 id 匹配永远失败、每折两次全冷。
怎么修的
src/snapshot/stage0.ts一处(+ 注释,共 +66/-3):pin 在 overlap 行漂移时不再一律放弃,先做一次逐行指纹——只有当每个漂移行的台账侧都是内容哈希 h_ 行、且客户端声明的 id 在整个台账里查无(命名空间整体换了一个新空间),才容忍这次漂移并照常规应用 pin:前缀从台账 write-once 行重铸,新核盖上声明的宿主 id。其余任何漂移(共享命名空间的真漂移、"?" 槽位、id 在台账他处出现)一律保持原来的 null 降级,issue5874-2x2-p3 的 I2/I3 契约原样不动。这就是 egress 台账遇到同一处境时
REANCHOR_NOW的答案(egress 从不 null);legacy 路径现在给出同样的答案,但用更保守的指纹(egress 按"全零匹配"放行,legacy 要求逐行 h_+外部 id,因为 legacy 的台账是位置对齐的,不是视图盖印)。收敛是一轮的:miss 轮走 raw,ingest sweep 把台账尾部对齐到声明的 uuid 空间,之后每一轮都是普通位置式 pin,不再触发该分支。分支首次触发时打一条有界的 per-session warn——这个分支之前是静默的,报告者的痛点之一就是静默。
不改 fold-reconcile 的日志级别、不改 fastpath 的 tail-ids 检查、不碰任何 config 字段;无 version bump(内容 commit,版本只在 release 分支动)。
验证
tests/issue7981-legacy-ns-jump.test.ts7 用例全绿:J1 全 h_ 台账+uuid tail 从 null 变为 pin 成功且仅一条 warn、幂等;J2 sweep 后已收敛台账走普通路径无 warn;J3a/J3b 混合台账过渡态不振荡;J4 宿主 id 台账上的真漂移仍降级(full);J5 overlap 位 "?" 仍降级;J6 漂移 id 在台账他处存在仍降级(指纹逐行非全列)。tests/issue5874-2x2-p3.test.ts43/43 原样全绿(I2/I3 契约未动)。follow-up(不在本 PR)